import request from '@/utils/request'

/**
 *  获取手机验证码
 * @param {*} mobile 手机号
 * @returns promise
 */

export function getCode (mobile) {
  return request({
    url: '/v1_0/sms/codes/' + mobile
  })
}

export function login (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data
  })
}

export function getUserSelfInfo () {
  return request({
    url: '/v1_0/user'
  })
}

export function getUserSelfChannels () {
  return request({
    url: '/v1_0/user/channels'
  })
}

export function addUserChannelItem (channel) {
  return request({
    url: '/v1_0/user/channels',
    method: 'PATCH',
    data: {
      channels: [channel]
    }
  })
}

export function removeUserChannelItem (id) {
  return request({
    url: '/v1_0/user/channels/' + id,
    method: 'DELETE'
  })
}
// 关注用户
/**
 *
 * @param {*} data  target关注用户id
 * @returns
 */
export function followUser (target) {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target: target
    }
  })
}

// 取消关注用户
/**
 *
 * @param {*} data  target关注用户id
 * @returns
 */
export function deleteUser (target) {
  return request({
    url: '/v1_0/user/followings/' + target,
    method: 'DELETE'
  })
}
